package com.topscore.uke.ui.activities;

import android.os.Bundle;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.topscore.uke.R;
import com.topscore.uke.entities.AchievementInfo;
import com.topscore.uke.mvp.contractors.GetAchievementContractor;
import com.topscore.uke.mvp.presenters.GetAchievementPresenter;
import com.topscore.uke.ui.ToolBarCompatActivity;

import butterknife.Bind;
import butterknife.ButterKnife;

public class MyGoldCoinsActivity extends ToolBarCompatActivity implements GetAchievementContractor.View {

    @Bind(R.id.total_coin_tv)
    TextView totalCoinTv;
    @Bind(R.id.tab_total)
    RelativeLayout tabTotal;
    @Bind(R.id.tab_exchanged)
    RelativeLayout tabExchanged;
    @Bind(R.id.tab_expired)
    RelativeLayout tabExpired;
    @Bind(R.id.exchange_button)
    Button exchangeButton;
    @Bind(R.id.fragment_container)
    FrameLayout fragmentContainer;
    @Bind(R.id.coin_tv)
    TextView coinTv;

    private GetAchievementContractor.Presenter mPresenter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my_gold_coins);
        ButterKnife.bind(this);
        setCentralTitle("我的金币");
        mPresenter = new GetAchievementPresenter(this);
        initViews();
    }

    private void initViews() {
        initData();
    }

    private void initData() {
        mPresenter.getPerformance();
    }

    @Override
    public void onGetPerformanceDataSuccess(AchievementInfo info) {
        totalCoinTv.setText(String.valueOf(info.getGoldCount()));
        coinTv.setText(String.valueOf(info.getGoldCount()));

    }

    @Override
    public void onLoading(String loadingMessage) {
        showLoadingDialog(loadingMessage);
    }

    @Override
    public void onLoadFinished() {
        dismissLoadingDialog();
    }

    @Override
    public void onFail(int code, String errorMessage) {
        Toast.makeText(mContext, errorMessage, Toast.LENGTH_SHORT).show();
    }
}
